package com.my.control.validate
{
	import com.my.commons.constants.ConstVars;
	import com.my.view.popup.RetrievePassView;
	
	import mx.core.UIComponent;
	
	public class RetrievePassValidate extends AbstractValidate implements IValidate
	{
		public function RetrievePassValidate(value:UIComponent)
		{
			super(value);
		}
		
		public override function validate():Boolean{
			var bool1:Boolean = usernameValidate();
			var bool2:Boolean = myResultValidate();
			return bool1 && bool2;
		}
		
		
		private function usernameValidate():Boolean{
			if(getView().username.text.match(ConstVars.NAME_REGEX)){
				getView().usernameTip.text = "";
				return true;
			}else{
				getView().usernameTip.text = ConstVars.NAME_TIP;
				return false;
			}
		}
		private function myResultValidate():Boolean{
			if(getView().myResult.text != null && getView().myResult.text != ""){
				getView().myResultTip.text = "";
				return true;
			}else{
				getView().myResultTip.text = "请输入答案";
				return false;
			}
		}
		
		
		
		
		public function getView():RetrievePassView{
			return RetrievePassView(view);
		}
	}
}